﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Resources;
using System.Globalization;

using TrainingCenterSystem;
using TrainingCenterSystem.UserManagement;
using TrainingCenterSystem.VocabularyManagement;



namespace TrainingCenterWinClient.Forms
{
    public partial class TestMainForm : Form
    {
        #region private members
        TrainingCenter _trainingCenter;
        CollectionHandler _collectionHandler;
        #endregion

        #region constructors  
        public TestMainForm(TrainingCenter trainingCenter, CollectionHandler collHandler)
        {
            InitializeComponent();
            _trainingCenter = trainingCenter;
            _collectionHandler = collHandler;
            this.initForm();
        }
        #endregion

        #region methods
        private void initForm()
        {
            this.UpdateLanguage(_trainingCenter.CurrentLanguageID);

            if (_trainingCenter.IsBasicVersion)
            {
                this.btnViewTest.Enabled = false;
                this.btnRunTest.Enabled = false;
            }
        }

        private void UpdateLanguage(string langID)
        {
            try
            {
                // Set Language
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(langID);

                // Init ResourceManager
                ResourceManager resMgr =
                    new ResourceManager("TrainingCenterWinClient.ReStrings",
                    typeof(TestMainForm).Assembly);

                // assign localized strings to UI                
                this.Text = resMgr.GetString("TestMainForm_caption");
                this.btnCreateTest.Text = resMgr.GetString("TestMainForm_btnCreateTest");
                this.btnRunTest.Text = resMgr.GetString("TestMainForm_btnRunTest");
                this.btnViewTest.Text = resMgr.GetString("TestMainForm_btnViewTest");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        #endregion

        private void btnCreateTest_Click(object sender, EventArgs e)
        {
            TestCreationUpdateForm createTestForm = new TestCreationUpdateForm(_trainingCenter, _collectionHandler);
            createTestForm.ShowDialog();
        }

        private void btnOpenTest_Click(object sender, EventArgs e)
        {

        }

        private void TestMainForm_Load(object sender, EventArgs e)
        {

        }
    }
}
